/*
 * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "rwnx_utils.h"
#include "system.h"

typedef struct {
    uint8_t cs_tkip_conf;
    uint8_t send_bar;
    uint8_t new_backoff_bw_rise_en;
    uint8_t wdt_en;
} wifi_feature_param_t;

typedef struct {
    uint8_t  beacon_linkloss_thd;
    uint8_t  ps_tx_error_max;
    uint16_t bam_inactivity_to_duration;
    uint32_t mm_keep_alive_period;
    uint32_t default_assocrsp_timeout;
    uint32_t default_authrsp_timeout;
    uint32_t scan_active_duration;
    uint32_t scan_passive_duration;
    uint32_t tx_ac0_timeout;
    uint32_t tx_ac1_timeout;
    uint32_t tx_ac2_timeout;
    uint32_t tx_ac3_timeout;
    uint32_t tx_bcn_timeout;
    uint32_t tx_hiq_timeout;
    uint16_t sdio_rx_buf_num_threshold;
    uint16_t sdio_rx_buf_rep_threshold;
    uint16_t deepsleep_notallowed_offset;
    uint16_t ps_activity_to_us;
    uint16_t ps_activity_bcmc_to_us;
    uint16_t ps_activity_uc_to_us;
    uint16_t lp_wakeup_offset;
    uint8_t  tx_he_tb_prog_time;
    uint8_t  tx_agg_finish_dur;
} thresh_param_t;

typedef struct {
    uint8_t host_type;
    uint16_t sdio_desc_cnt;
    uint16_t pkt_cnt_128;
    uint16_t pkt_cnt_1600;
    uint16_t pkt_cnt_1724;
    uint32_t ipc_base_addr;
    uint32_t buf_base_addr;
    uint32_t desc_base_addr;
    uint32_t desc_size;
    uint32_t pkt_base_addr;
    uint32_t pkt_size;
    uint32_t txdesc_cnt[5];
    uint32_t reord_buf_size;
} host_if_param_t;

typedef struct {
    uint32_t rx_ringbuf_start1;
    uint32_t rx_ringbuf_size1;
    uint32_t rx_ringbuf_start2;
    uint32_t rx_ringbuf_size2;
} rx_ringbuf_conf_t;

typedef struct {
    uint32_t ac_param[4];
} ac_param_conf_t;

typedef struct {
    uint8_t fix_txgain_en;
    uint8_t fix_txgain_val;
    uint8_t fix_txgain_val_5g;
    uint8_t fix_1024qam_txgain;
} txgain_conf_t;

typedef struct {
    wifi_feature_param_t wifi_feature_param;
    thresh_param_t thresh_param;
    host_if_param_t host_if_param;
    rx_ringbuf_conf_t rx_ringbuf_conf;
    ac_param_conf_t ac_param_conf;
    uint32_t clkgate_en_config;
    uint32_t uart_config;
    uint8_t lp_level;
    uint8_t bt_use_wifi_rf;
    uint16_t debug_mask;
    txgain_conf_t txgain_config;
    uint16_t pwr_close_sysdelay;
    uint16_t pwr_open_sysdelay;
    uint8_t use_5g;
    uint8_t clkgate_use_hwbcn;
    uint8_t poweroff_use_hwbcn;
    #if (CFG_ROM_VER >= 3)
    //append configuration for u03
    uint8_t fix_txgain_val_24g_11b;
    uint8_t sdio_send_ampdu;
    uint8_t sdio_send_ampdu_blkcnt_thresh;
    #endif
} wifi_settings_t;

#define JUMP_TABLE_BASE_U02     0x00171A30
#define KE_EVT_HDLR_BASE_U02    0x001720C4
#define JUMP_TABLE_BASE_U03     0x00171A3C
#define KE_EVT_HDLR_BASE_U03    0x001720E0
#define SCANU_SCANING_BASE_U03  0x00172438

#define JUMP_TABLE_BASEx(v)     MCAT(JUMP_TABLE_BASE_U0, v)
#define JUMP_TABLE_BASE         JUMP_TABLE_BASEx(CFG_ROM_VER)
#define KE_EVT_HDLR_BASEx(v)    MCAT(KE_EVT_HDLR_BASE_U0, v)
#define KE_EVT_HDLR_BASE        KE_EVT_HDLR_BASEx(CFG_ROM_VER)

#define WIFI_SETTINGS_OFST(mem) (((uint32_t) &((wifi_settings_t *)0)->mem) & ~0x03UL)
#define JUMP_TABLE_OFSTx(i,v)   ((uint32_t)(MCAT(JUMP_TABLE_BASE_U0, v)+(i)*4))
#define JUMP_TABLE_OFST(i)      JUMP_TABLE_OFSTx(i, CFG_ROM_VER)
#define KE_EVT_HDLR_OFSTx(i,v)  ((uint32_t)(MCAT(KE_EVT_HDLR_BASE_U0, v)+(i)*8))
#define KE_EVT_HDLR_OFST(i)     KE_EVT_HDLR_OFSTx(i, CFG_ROM_VER)
#define SCANU_SCANING_OFSTx(i,v)  ((uint32_t)(MCAT(SCANU_SCANING_BASE_U0, v)+(i)*8 + 4))

uint32_t VAR_WITH_VERx(patch_tbl, 2)[][2] =
{
    {WIFI_SETTINGS_OFST(thresh_param.lp_wakeup_offset), 0x080503e8}, // .lp_wakeup_offset = 1000, .tx_he_tb_prog_time = 5, .tx_agg_finish_dur = 8
    {WIFI_SETTINGS_OFST(host_if_param.host_type),       0x00000003}, // .host_type = 3,.sdio_desc_cnt = 0
    {WIFI_SETTINGS_OFST(host_if_param.pkt_cnt_128),     0x00000000}, // .pkt_cnt_128, .pkt_cnt_1600 = 0
    #if PLF_WIFI_AUDIO
    #ifdef CFG_SOFTAP
    {WIFI_SETTINGS_OFST(host_if_param.pkt_cnt_1724),    0x00000011},
    #else
    {WIFI_SETTINGS_OFST(host_if_param.pkt_cnt_1724),    0x00000011},
    #endif
    #else
    {WIFI_SETTINGS_OFST(host_if_param.pkt_cnt_1724),    0x00000011},
    #endif
    {WIFI_SETTINGS_OFST(host_if_param.buf_base_addr),   0x00000000},
    {WIFI_SETTINGS_OFST(host_if_param.desc_base_addr),  0x00000000},
    {WIFI_SETTINGS_OFST(host_if_param.desc_size),       0x00000000},
    {WIFI_SETTINGS_OFST(host_if_param.pkt_size),        0x00007800},
    #if (PLF_BT_STACK || PLF_BLE_STACK) && (PLF_WIFI_STACK)
    {WIFI_SETTINGS_OFST(host_if_param.ipc_base_addr),   0x00190000},
    {WIFI_SETTINGS_OFST(host_if_param.pkt_base_addr),   0x00190800},
    #else
    {WIFI_SETTINGS_OFST(host_if_param.ipc_base_addr),   0x00190000},
    {WIFI_SETTINGS_OFST(host_if_param.pkt_base_addr),   0x00190800},
    #endif
    {WIFI_SETTINGS_OFST(host_if_param.txdesc_cnt[0]),   NX_TXDESC_CNT0},
    {WIFI_SETTINGS_OFST(host_if_param.txdesc_cnt[1]),   NX_TXDESC_CNT1},
    {WIFI_SETTINGS_OFST(host_if_param.txdesc_cnt[2]),   NX_TXDESC_CNT2},
    {WIFI_SETTINGS_OFST(host_if_param.txdesc_cnt[3]),   NX_TXDESC_CNT3},
    {WIFI_SETTINGS_OFST(host_if_param.txdesc_cnt[4]),   NX_TXDESC_CNT4},
    {WIFI_SETTINGS_OFST(host_if_param.reord_buf_size),  NX_REORD_BUF_SIZE},
    {WIFI_SETTINGS_OFST(rx_ringbuf_conf.rx_ringbuf_start1), 0x00000000},
    {WIFI_SETTINGS_OFST(rx_ringbuf_conf.rx_ringbuf_start2), 0x00000000},
    #if FRAMES_11MBPS_ENABLED
    #if defined(CFG_WIFI_VOICE_ROLE_DONGLE)
    {WIFI_SETTINGS_OFST(thresh_param.tx_ac0_timeout),   40000}, // 40ms
    {WIFI_SETTINGS_OFST(thresh_param.tx_ac1_timeout),   40000}, // 40ms
    {WIFI_SETTINGS_OFST(thresh_param.tx_ac2_timeout),   40000}, // 40ms
    {WIFI_SETTINGS_OFST(thresh_param.tx_ac3_timeout),   40000}, // 40ms
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[0]),     0x00000a47},
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[1]),     0x00000643},
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[2]),     0x0005e431},
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[3]),     0x0002f321},
    #else
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[0]),     0x00000000},
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[1]),     0x00000000},
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[2]),     0x00000000},
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[3]),     0x00000000},
    #endif
    #endif /* FRAMES_11MBPS_ENABLED */
#if CONFIG_SLEEP_LEVEL == 0
    {WIFI_SETTINGS_OFST(lp_level), 0x8d0a0000}, // .lp_level = 0, .bt_use_wifi_rf = 0, .debug_mask=0x8d0a
#elif CONFIG_SLEEP_LEVEL == 1
    {WIFI_SETTINGS_OFST(lp_level), 0xffff0001}, // .lp_level = 1, .bt_use_wifi_rf = 0, .debug_mask=0xffff
#elif CONFIG_SLEEP_LEVEL >= 2
    {WIFI_SETTINGS_OFST(lp_level), 0xffff0002}, // .lp_level = 2, .bt_use_wifi_rf = 0, .debug_mask=0xffff
#endif
    #if PLF_BAND5G
    // Attention, GPIOs used by 5g fem maybe conflict with audio I2SM.
    {WIFI_SETTINGS_OFST(txgain_config.fix_txgain_en),   0xd0e0d003}, // .fix_txgain_en = 3, .fix_txgain_val = 0xd0, .fix_txgain_val_5g = 0xe0, .fix_1024qam_txgain = 0xd0
    {WIFI_SETTINGS_OFST(use_5g),                        0x00010001}, // .use_5g = 1, .clkgate_use_hwbcn = 0, .poweroff_use_hwbcn = 1
    #else
    {WIFI_SETTINGS_OFST(txgain_config.fix_txgain_en),   0xd0e0f301}, // .fix_txgain_en = 1, .fix_txgain_val = 0xf3, .fix_txgain_val_5g = 0xe0, .fix_1024qam_txgain = 0xd0
    #endif
};

uint32_t VAR_WITH_VERx(patch_tbl_func, 2)[][2] =
{
    { JUMP_TABLE_OFSTx( 53, 2), 0x001cebdd }, //hal_machw_abs_timer_handler_patch
    { JUMP_TABLE_OFSTx( 86, 2), 0x001ce10d }, //me_build_associate_req_patch
    { JUMP_TABLE_OFSTx(136, 2), 0x001ce531 }, //phy_get_rf_gain_idx_patch
    { JUMP_TABLE_OFSTx(171, 2), 0x001ce595 }, //rxl_payload_transfer_patch
    { JUMP_TABLE_OFSTx(297, 2), 0x001ce6ad }, //phy_rf_add_config_24g_patch
    { JUMP_TABLE_OFSTx(299, 2), 0x001ce6bd }, //phy_rf_add_config_5g_patch
    { KE_EVT_HDLR_OFSTx( 0, 2), 0x001ce77d }, //rwnxl_reset_evt_patch
    { JUMP_TABLE_OFSTx(106, 2), 0x001ce929 }, //mm_init_patch
    { JUMP_TABLE_OFSTx(154, 2), 0x001ced15 }, //rc_check_patch
    { JUMP_TABLE_OFSTx( 97, 2), 0x001cee95 }, //mm_bcn_transmit
    { JUMP_TABLE_OFSTx( 98, 2), 0x001cefd9 }, //mm_bcn_transmitted
};

uint32_t VAR_WITH_VERx(patch_func, 2)[] =
{
    0x4a0f480e,
    0x490f6803,
    0x03fff023,
    0x03c2f043,
    0x68136003,
    0x03fff023,
    0x03c2f043,
    0x68036013,
    0x237ff423,
    0x233ff443,
    0x68136003,
    0x237ff423,
    0x233ff443,
    0x601320c2,
    0x477071c8,
    0x4033b3ac,
    0x4033b3d4,
    0x001cf174,
    0x61647075,
    0x20236574,
    0x2064253d,
    0x0a0d6425,
    0x00000000,
    0x48254b24,
    0xe92d681b,
    0x4d2441f0,
    0x796a4f24,
    0x1007f995,
    0x4e23683c,
    0x030ff003,
    0xb252441a,
    0xf06f1a89,
    0x4299033d,
    0x4619bfb8,
    0xfc81fa5f,
    0x04fff024,
    0x040cea44,
    0x6833603c,
    0x03fff023,
    0x030cea43,
    0x683c6033,
    0xfa5f1ecb,
    0xf424fc83,
    0xea44247f,
    0x603c340c,
    0xf4236833,
    0xb24c237f,
    0x330cea43,
    0x46216033,
    0xf66171ec,
    0x343df8e5,
    0x4b0ddb0e,
    0x691a8929,
    0xf2474b0c,
    0xf1055430,
    0xfb04000c,
    0xf8d32101,
    0xe8bd31e0,
    0x471841f0,
    0x81f0e8bd,
    0x4032011c,
    0x001ce048,
    0x001cf174,
    0x4033b3ac,
    0x4033b3d4,
    0x40501000,
    0x00171a30,
    0x4ff0e92d,
    0x460db08f,
    0x8f3c9f1a,
    0x8036f8b7,
    0x2c004601,
    0xbf084618,
    0x46162405,
    0xf6639107,
    0xf8b5fda9,
    0x9b0790ae,
    0x0910f009,
    0x0009ea40,
    0x0240f107,
    0x9202805c,
    0xfa1f8018,
    0x4614f980,
    0xf0002e00,
    0x883281d9,
    0x8872809a,
    0x88b280da,
    0x220a811a,
    0x98184616,
    0x60011899,
    0x0c00f04f,
    0x007ef895,
    0xf8039107,
    0x9b07c002,
    0x0e02f100,
    0x28007058,
    0x80bcf040,
    0xf8959907,
    0xeb0e20b0,
    0x23010001,
    0xf80e9007,
    0x9b073001,
    0x46942a08,
    0xf04fbf28,
    0xf8830c08,
    0x9907c001,
    0xfe8efa1f,
    0x0a02f10c,
    0x03b1f105,
    0xf10cb152,
    0x44ac0cb1,
    0x0b01f813,
    0x1b52185a,
    0xf802459c,
    0xd1f70cb0,
    0x20b0f895,
    0xeb0a44d6,
    0x2a080301,
    0x93074476,
    0x2332d91b,
    0x3001f80a,
    0xf1a29b07,
    0x70590108,
    0x0cb1f102,
    0x44ac9907,
    0x0e06f1a2,
    0x03b9f105,
    0x0b01f813,
    0x1b52185a,
    0xf802459c,
    0xd1f70cb8,
    0x0301eb0e,
    0x93074476,
    0xf419b2b6,
    0xd17d7f80,
    0x0f00f1b8,
    0x9a02d00b,
    0x46104442,
    0x0240f1a4,
    0x1b01f814,
    0x42841bd2,
    0xd1f754d1,
    0xf8d59b07,
    0x444640e0,
    0x07e24443,
    0x9307b2b6,
    0x4ab4d51a,
    0xaf0aca07,
    0x2000c703,
    0x803aa90a,
    0x0036f8ad,
    0x0032f8cd,
    0x0030f88d,
    0xa80c1a5b,
    0xe00122dd,
    0x2f01f811,
    0x4288545a,
    0x9b07d1fa,
    0x33093609,
    0x9307b2b6,
    0xd50507a7,
    0xf8934ba6,
    0x07dc3176,
    0x80daf100,
    0x7d9b4ba4,
    0xf0002b01,
    0xf8d580e1,
    0x071830e0,
    0x4a9fd505,
    0x2176f892,
    0xf1000751,
    0x075a80c1,
    0x4d9bd51a,
    0x3176f895,
    0xd515079b,
    0xa8074c9a,
    0x3150f8d4,
    0x44064798,
    0xf8d48f28,
    0xf663714c,
    0xf895fb8b,
    0x2a042175,
    0xbf084601,
    0xa8072203,
    0xb2b647b8,
    0xb2864430,
    0x681a9b18,
    0x1a9b9b07,
    0x46309a19,
    0xb00f8013,
    0x8ff0e8bd,
    0x9907307f,
    0xf1054428,
    0xf813037f,
    0x185acb01,
    0x42981b52,
    0xcc7ef802,
    0xe736d1f7,
    0x22211c59,
    0x701a9107,
    0x22029b07,
    0x91071c59,
    0x701aa80a,
    0x0127f10d,
    0xff8ef642,
    0x30a4f8d5,
    0x2028f99d,
    0x3004f993,
    0xbfc8429a,
    0x3028f88d,
    0xf89d9b07,
    0x1c592027,
    0x701a9107,
    0xf89d9b07,
    0x1c592028,
    0x701a9107,
    0x22249b07,
    0x91071c59,
    0x9b07701a,
    0x461a9303,
    0x0b01f102,
    0x30a4f8d5,
    0xb01cf8cd,
    0x4a68789b,
    0xf0402b00,
    0x23018083,
    0xa172f892,
    0x32769304,
    0x0f00f1ba,
    0x80bcf000,
    0x95062100,
    0x46089101,
    0x9605468e,
    0x460d46a1,
    0xf01378d3,
    0xd1200302,
    0xf8b27894,
    0x2c00c000,
    0xf6acd173,
    0x2c48146c,
    0xf640d86a,
    0x459c13b4,
    0x809ff000,
    0xf6ac4c57,
    0xfba41367,
    0x089c4303,
    0x0387f3c3,
    0xd0742800,
    0x0e0eeba4,
    0x45a69c04,
    0x3001d173,
    0x469eb2c0,
    0x31013206,
    0x459ab2cb,
    0x9b01d8d6,
    0xf1039e05,
    0x46290e02,
    0xf38efa5f,
    0x464c9d06,
    0xf10b469e,
    0x92070201,
    0x1000f88b,
    0x1c519a07,
    0x70109107,
    0x36069a03,
    0xfa1e7013,
    0x9b07f686,
    0xe6f5b2b6,
    0xa8074b3d,
    0x3144f8d3,
    0x44064798,
    0x30e0f8d5,
    0xe734b2b6,
    0xa8074b38,
    0x3148f8d3,
    0x4b354798,
    0x44067d9b,
    0xb2b62b01,
    0xaf1ff47f,
    0x30e4f8b5,
    0xf43f2b00,
    0x9b07af1a,
    0x701a2236,
    0x22039b07,
    0x9b07705a,
    0x20e4f8b5,
    0xf895805a,
    0x711a20e6,
    0x36059b07,
    0xb2b63305,
    0xe7069307,
    0xf8922304,
    0x9304a173,
    0xe77b32ca,
    0x4686b9d8,
    0x20014605,
    0x2c01e7a6,
    0xf5acd1f8,
    0xf1ac5c9c,
    0xb2a4040d,
    0x7f4df5b4,
    0x4b1dd8f0,
    0x0c08f1ac,
    0x430cfba3,
    0xf3c3089c,
    0x28000387,
    0x469ed18a,
    0x2001461d,
    0xf10be78e,
    0x94070401,
    0x5000f88b,
    0x9e019c07,
    0x0c01f104,
    0x0e02f106,
    0xc01cf8cd,
    0x0c02f100,
    0xfa5f7020,
    0x9001f08e,
    0xb01cf8dd,
    0xfa5f469e,
    0xe775f08c,
    0x46162204,
    0x230ee62b,
    0xe765461c,
    0x46502302,
    0x469e4651,
    0xbf00e779,
    0x001cf0fc,
    0x0017a804,
    0x0017a984,
    0x00171a30,
    0xcccccccd,
    0xf8934b0c,
    0xb953302a,
    0xf8934b0b,
    0x07c000ac,
    0xf893d50e,
    0x700b30ad,
    0x701323e6,
    0x4b064770,
    0x00acf893,
    0xd5030780,
    0x30aef893,
    0x7013700b,
    0xbf004770,
    0x00173164,
    0x0017192c,
    0x5f6c7872,
    0x6c796170,
    0x5f64616f,
    0x6e617274,
    0x72656673,
    0x7461705f,
    0x00006863,
    0x21206470,
    0x554e203d,
    0x00004c4c,
    0x4ff0e92d,
    0x68074c3e,
    0x881d6824,
    0xc000f894,
    0xb100f8df,
    0xf5b1b083,
    0x9e0c6fc8,
    0xeb069301,
    0xbf280646,
    0x61c8f44f,
    0x0f03f1bc,
    0x4b35bf08,
    0xeb079000,
    0xf1061606,
    0x46900614,
    0x601ebf08,
    0xe02d2000,
    0x0403ebae,
    0x440c442c,
    0xb2a41b52,
    0x2500b291,
    0x0f03f1bc,
    0xf5b1d10d,
    0x460b6f00,
    0xf44fbf28,
    0xf0436300,
    0xf04f4323,
    0x60b31204,
    0x613160f1,
    0x44886172,
    0xf8dbb3ac,
    0xf8d73000,
    0xf9b39004,
    0x2b003000,
    0x0a14f109,
    0xf1bcdb1b,
    0xd1010f03,
    0xa020f8c6,
    0x46564638,
    0x4621464f,
    0x4302e9d7,
    0xfa1f3301,
    0xb29bfe84,
    0x020eeba3,
    0xeb01b292,
    0x442c0905,
    0xf8c64591,
    0x60348004,
    0x2400dac0,
    0xf1b9e7c6,
    0xd1e00f00,
    0x480f4b0e,
    0x30c4f8d3,
    0xf240490e,
    0x479812d1,
    0x681b4b08,
    0xc000f893,
    0xf1bce7d3,
    0xd1020f03,
    0x62344b05,
    0x9b00605e,
    0x9b01601f,
    0xb003801d,
    0x8ff0e8bd,
    0x00173274,
    0x00175aa0,
    0x00171a30,
    0x001ce588,
    0x001ce56c,
    0x00173250,
    0x68134a02,
    0x0380f423,
    0x47706013,
    0x40344014,
    0x4382f241,
    0xb4104298,
    0x4b17d825,
    0x601a4a17,
    0x4c184917,
    0x4818680b,
    0xf0234a18,
    0x600b6380,
    0xf023680b,
    0xf043030f,
    0x600b0308,
    0xf0236823,
    0xf04363c0,
    0x60236380,
    0xf85d6803,
    0xf4434b04,
    0x60036370,
    0xf4236813,
    0x60130300,
    0xf4436813,
    0x60130380,
    0xf2414770,
    0x42986344,
    0xbf944b02,
    0x4a084a07,
    0xe7d3601a,
    0x40344030,
    0x7a2a5008,
    0x40344038,
    0x4034403c,
    0x40580108,
    0x40344014,
    0x791b50c8,
    0x7a2ad0c8,
    0x786e7772,
    0x65725f6c,
    0x5f746573,
    0x5f747665,
    0x63746170,
    0x000a0d68,
    0x61647075,
    0x25206574,
    0x25202c64,
    0x000a0d64,
    0x65736572,
    0x6f642074,
    0x0a0d656e,
    0x00000000,
    0x41f0e92d,
    0x8310f3ef,
    0xd40307db,
    0x4b57b672,
    0x601a2201,
    0x49574c56,
    0x4d576823,
    0xf44f3301,
    0x60236080,
    0xfdc8f660,
    0x4000f04f,
    0xfbc6f65f,
    0x30ecf8d5,
    0x4b514798,
    0x68194a51,
    0x417ff021,
    0x68196019,
    0x0110f041,
    0x69116019,
    0x69133164,
    0x2b001acb,
    0x4e4bdafb,
    0x2410f8d5,
    0x4f4a6833,
    0x7388f443,
    0x0301f043,
    0x47906033,
    0x68134a43,
    0x0310f023,
    0x68336013,
    0x7388f423,
    0x0301f023,
    0xf6556033,
    0xf654fa9d,
    0x79bbf801,
    0xd04f2b00,
    0x681b4b3e,
    0x2b03781b,
    0x783bd05a,
    0xd0472b00,
    0x797e4b3b,
    0xf997681a,
    0xf9973007,
    0xf8dfe004,
    0x4838c0f8,
    0x1000f8dc,
    0x81e0f8d5,
    0xf0024d30,
    0x4416020f,
    0x4433b276,
    0xbfa84573,
    0xfa5f4673,
    0xf021fe83,
    0xea4101ff,
    0xf8cc010e,
    0x68021000,
    0x02fff022,
    0x020eea42,
    0xf8dc6002,
    0x1eda1000,
    0xfe82fa5f,
    0x217ff421,
    0x310eea41,
    0x1000f8cc,
    0xf8b76802,
    0xf422c008,
    0xea42227f,
    0x6002320e,
    0x4821692a,
    0xf64eb25d,
    0xfb012160,
    0x71fd210c,
    0x230047c0,
    0x71bb481d,
    0x46324629,
    0xfcf4f660,
    0xf44f491b,
    0xf6606080,
    0x6823fd3f,
    0x4a0bb133,
    0x68123b01,
    0xb90b6023,
    0xb662b102,
    0x81f0e8bd,
    0x681b4b14,
    0x601a2200,
    0xfccef645,
    0x2b00783b,
    0x79bbd0e6,
    0xd19b2b00,
    0xbf00e7e2,
    0x0017569c,
    0x00172600,
    0x001ce744,
    0x00171a30,
    0x40320400,
    0x40501000,
    0x40340018,
    0x001cf174,
    0x00173274,
    0x4032011c,
    0x4033b3d4,
    0x001cf180,
    0x001ce75c,
    0x001ce76c,
    0x00180000,
    0x4033b3ac,
    #if FRAMES_11MBPS_ENABLED
    0x4d40b570,
    0x78ab4c40,
    0xf8d4b913,
    0x479830e4,
    0xfceef654,
    0xff2af653,
    0xfcc0f653,
    0xfa16f65d,
    0xfb76f65b,
    0xfbe6f65c,
    0x338cf8d4,
    0x78ab4798,
    0x4a374836,
    0x4503f240,
    0x61452108,
    0x2b006151,
    0xf652d058,
    0x4d33fc4b,
    0x781b682b,
    0xd454079e,
    0xfe6af657,
    0xfb82f65d,
    0x47986e63,
    0x317cf8d4,
    0x4b2d4798,
    0x789a482d,
    0x4001f993,
    0x70192101,
    0x70d92114,
    0xf3c16801,
    0xf0410115,
    0x3a147120,
    0xb2526001,
    0x013df06f,
    0xbfb8428a,
    0x42a2460a,
    0x00c2f04f,
    0x682971d8,
    0x62184821,
    0x4622bfa8,
    0x4c20260a,
    0xf44f715e,
    0x711a757a,
    0x811d611c,
    0x788b481d,
    0x06dc6802,
    0xf022bf4c,
    0xf0424200,
    0x60024200,
    0xf0134a19,
    0x68130f01,
    0xf443bf14,
    0xf4232380,
    0x60132380,
    0x68134a15,
    0x6300f043,
    0x784b6013,
    0xf5a2b12b,
    0x68137207,
    0x0340f043,
    0xbd706013,
    0xfbe8f652,
    0x2003e7a5,
    0xfffcf645,
    0xbf00e7a6,
    0x00173254,
    0x00171a30,
    0x001804c4,
    0x00180484,
    #else
    0x4d42b570,
    0x78ab4c42,
    0xf8d4b913,
    0x479830e4,
    0xfceef654,
    0xff2af653,
    0xfcc0f653,
    0xfa16f65d,
    0xfb76f65b,
    0xfbe6f65c,
    0x338cf8d4,
    0xbf004798,
    0xbf00bf00,
    0xbf00bf00,
    0xbf00bf00,
    0xbf00bf00,
    0xbf00bf00,
    0x78abbf00,
    0xd0582b00,
    0xfc46f652,
    0x682b4d30,
    0x079e781b,
    0xf657d454,
    0xf65dfe65,
    0x6e63fb7d,
    0xf8d44798,
    0x4798317c,
    0x482b4b2a,
    0xf993789a,
    0x21014001,
    0x21147019,
    0x680170d9,
    0x0115f3c1,
    0x7120f041,
    0x60013a14,
    0xf06fb252,
    0x428a013d,
    0x460abfb8,
    0xf04f42a2,
    0x71d800c2,
    0x481f6829,
    0xbfa86218,
    0x260a4622,
    0x715e4c1d,
    0x757af44f,
    0x611c711a,
    0x481b811d,
    0x6802788b,
    0xbf4c06dc,
    0x4200f022,
    0x4200f042,
    0x4a176002,
    0x0f01f013,
    0xbf146813,
    0x2380f443,
    0x2380f423,
    0x4a136013,
    0xf0436813,
    0x60136300,
    0xb12b784b,
    0x7207f5a2,
    0xf0436813,
    0x60130340,
    0xf652bd70,
    0xe7a5fbe3,
    0xf6452003,
    0xe7a6fff7,
    0x00173254,
    0x00171a30,
    #endif
    0x0017324c,
    0x001cf174,
    0x403200f0,
    0x001ce001,
    0x001ce05d,
    0x40320480,
    0x40320310,
    0x40320440,
    0x6f727265,
    0x74203a72,
    0x65726568,
    0x20736920,
    0x6b206f6e,
    0x69742065,
    0x2072656d,
    0x67206e69,
    0x74206e65,
    0x72656d69,
    0x796e6120,
    0x65726f6d,
    0x00000a0d,
    0x6f727265,
    0x74203a72,
    0x65726568,
    0x20736920,
    0x6d206f6e,
    0x6974206d,
    0x2072656d,
    0x67206e69,
    0x74206e65,
    0x72656d69,
    0x796e6120,
    0x65726f6d,
    0x00000a0d,
    0x69742821,
    0x5f72656d,
    0x646e6570,
    0x20676e69,
    0x41482026,
    0x43415f4c,
    0x49545f30,
    0x5f52454d,
    0x29544942,
    0x00000000,
    0x69742821,
    0x5f72656d,
    0x646e6570,
    0x20676e69,
    0x41482026,
    0x43415f4c,
    0x49545f31,
    0x5f52454d,
    0x29544942,
    0x00000000,
    0x69742821,
    0x5f72656d,
    0x646e6570,
    0x20676e69,
    0x41482026,
    0x43415f4c,
    0x49545f32,
    0x5f52454d,
    0x29544942,
    0x00000000,
    0x69742821,
    0x5f72656d,
    0x646e6570,
    0x20676e69,
    0x41482026,
    0x43415f4c,
    0x49545f33,
    0x5f52454d,
    0x29544942,
    0x00000000,
    0x69742821,
    0x5f72656d,
    0x646e6570,
    0x20676e69,
    0x41482026,
    0x44495f4c,
    0x545f454c,
    0x52454d49,
    0x5449425f,
    0x00000029,
    0x69742821,
    0x5f72656d,
    0x646e6570,
    0x20676e69,
    0x41482026,
    0x45485f4c,
    0x5f42545f,
    0x454d4954,
    0x49425f52,
    0x00002954,
    0x69742821,
    0x5f72656d,
    0x646e6570,
    0x20676e69,
    0x41482026,
    0x49485f4c,
    0x49545f51,
    0x5f52454d,
    0x29544942,
    0x00000000,
    0x4b3c4a3b,
    0x6814b510,
    0x0561601c,
    0x05e2d41d,
    0x05a3d416,
    0x06e0d410,
    0x4b37d431,
    0xb122781a,
    0x0f2ff014,
    0x2201bf1c,
    0x4b34719a,
    0xf9b3681b,
    0x2b003000,
    0xbd10db0d,
    0xf6604831,
    0xe7fefb3d,
    0xfad4f652,
    0xd5e605a3,
    0x482ee7f6,
    0xfb34f660,
    0x07e1e7fe,
    0x07a2d41c,
    0x0763d442,
    0x0720d438,
    0x0621d42e,
    0x0662d424,
    0x06a3d41a,
    0xe8bdd5e3,
    0x49254010,
    0xf2404825,
    0xf660326e,
    0x2004bcc1,
    0xf81ef64d,
    0x4180f04f,
    0xf64d2004,
    0xe7c4f8a7,
    0x4010e8bd,
    0x481e491c,
    0x3265f240,
    0xbcb0f660,
    0x4010e8bd,
    0x481b4918,
    0x725bf44f,
    0xbca8f660,
    0x4010e8bd,
    0x48184914,
    0x326af240,
    0xbca0f660,
    0x4010e8bd,
    0x48154910,
    0x725af44f,
    0xbc98f660,
    0x4010e8bd,
    0x4812490c,
    0x3267f240,
    0xbc90f660,
    0x4010e8bd,
    0x480f4908,
    0x3266f240,
    0xbc88f660,
    0x40328084,
    0x40328088,
    0x001cf174,
    0x00173250,
    0x001cea90,
    0x001cea5c,
    0x001cf10c,
    0x001cebb4,
    0x001ceac4,
    0x001ceb8c,
    0x001ceb64,
    0x001ceb3c,
    0x001ceb14,
    0x001ceaec,
    0x735f6372,
    0x3d212073,
    0x4c554e20,
    0x0000004c,
    0x41f0e92d,
    0x602cf890,
    0xb0822e09,
    0xf2004604,
    0x4b4f8081,
    0x681a4f4f,
    0x1386eb06,
    0x2000f9b2,
    0x03c3eb07,
    0xf8d32a00,
    0xea4f5148,
    0xdb681886,
    0xf8956b62,
    0xf3c230a1,
    0x07595240,
    0x2007f88d,
    0xf003d45a,
    0x682b02fd,
    0xf8854943,
    0x690a20a1,
    0x33c3f503,
    0x429333a0,
    0x1ad1d862,
    0xda042900,
    0x43d2493e,
    0x428b4413,
    0x2100d95e,
    0xf66d4628,
    0xf895fb85,
    0x493830a2,
    0x22003301,
    0x0303f003,
    0x30a2f885,
    0x209bf885,
    0x20a3f885,
    0x602a690a,
    0xf884009b,
    0xb1903046,
    0x0107f10d,
    0xf66c4628,
    0xf89dfedb,
    0x2b003007,
    0xeb08d04c,
    0xeb070306,
    0xf89303c3,
    0xf0422152,
    0xf8830211,
    0x46282152,
    0xf910f66d,
    0x8de2b1a8,
    0x3046f894,
    0x1007f89d,
    0x5200f442,
    0x0303f023,
    0xf88485e2,
    0xbb613046,
    0xeb074446,
    0xf89707c6,
    0xf0433152,
    0xf8870320,
    0xb0023152,
    0x81f0e8bd,
    0xd0a22a00,
    0x0202f043,
    0x2d00e7a1,
    0x4916d194,
    0xf2404816,
    0xf660329a,
    0xe78dfc0d,
    0xf8802300,
    0xb0023046,
    0x81f0e8bd,
    0x1a9b4911,
    0xd8a0428b,
    0x20a2f895,
    0x30a3f895,
    0x0382ea43,
    0x3046f884,
    0x6b63e7c1,
    0x1320f443,
    0xe7cd6363,
    0xf4236b63,
    0x63631300,
    0xbf00e7ad,
    0x00173250,
    0x00175aa8,
    0x40501000,
    0x0001869f,
    0x001cf130,
    0x001ced04,
    0x000186a0,
    0x5f6d6d21,
    0x5f6e6362,
    0x2e766e65,
    0x635f7874,
    0x00006d66,
    0x4ff8e92d,
    0x4a414b40,
    0x6894681b,
    0x3000f9b3,
    0x2b004e3f,
    0x7a75db41,
    0xd14a2d00,
    0x72354a3d,
    0x017f6817,
    0xf8dfb16c,
    0xf8df90f8,
    0x46aa80f8,
    0x0b01f04f,
    0x3062f894,
    0xd0042b02,
    0x2c006824,
    0xe8bdd1f8,
    0xf8948ff8,
    0x2b0030da,
    0xf894d0f6,
    0x2b003064,
    0xf894d0f2,
    0xf89420d9,
    0x429a30d8,
    0xf8d9d1ec,
    0x46203170,
    0xb1204798,
    0x3000f898,
    0xf8883301,
    0xf1bb3000,
    0xd0050f00,
    0x0232f1a7,
    0x33b6f640,
    0xd818429a,
    0x4620b9d5,
    0xfe6ef65a,
    0xb9f04683,
    0x5000f888,
    0x6873e7d0,
    0xd0ba2b00,
    0x481e491d,
    0x727af44f,
    0xfb80f660,
    0x2d007a75,
    0x2301d0b4,
    0xe8bd7233,
    0x46208ff8,
    0xfe56f65a,
    0xa000f888,
    0xf04f6824,
    0x25010b00,
    0xd1b12c00,
    0xf894e7b7,
    0xf8843063,
    0x23ff3097,
    0x3098f884,
    0xf1042104,
    0xf64d006c,
    0x6873ff9b,
    0x3301b108,
    0x2b016073,
    0xf04fd002,
    0xe79f0b00,
    0xfc82f655,
    0x0b00f04f,
    0xbf00e79a,
    0x00173250,
    0x00177720,
    0x00178bf8,
    0x40328040,
    0x001cf140,
    0x001cee80,
    0x00171a30,
    0x001cf1a0,
    0x625f6d6d,
    0x655f6e63,
    0x742e766e,
    0x66635f78,
    0x0000006d,
    0x6d5f6362,
    0x000a0d63,
    0x43f8e92d,
    0x4c3f4b3e,
    0x6865681b,
    0x3000f9b3,
    0x46072b00,
    0x3d01db04,
    0xb1756065,
    0x83f8e8bd,
    0xd1f82d00,
    0x48394938,
    0x4257f240,
    0xfb1cf660,
    0x3d016865,
    0x2d006065,
    0x4e35d1f0,
    0xfc9af655,
    0xbb4b7833,
    0xbb037aa3,
    0xb16368e3,
    0x80c8f8df,
    0xf8d84e30,
    0x463051d4,
    0xf844f65f,
    0x47a8300c,
    0x2b0068e3,
    0xf897d1f5,
    0x44040063,
    0xb1197d21,
    0xf8d34b29,
    0x47983190,
    0x30dff897,
    0xd1cd2b01,
    0xe8bd4638,
    0xf65343f8,
    0xf8dfbf8b,
    0x6820808c,
    0x318cf8d8,
    0xe7d74798,
    0xf6604820,
    0x2303f90f,
    0x8063f897,
    0x210b462a,
    0xf65e204a,
    0xf108fb41,
    0xfa5f080a,
    0xf880f888,
    0x70458000,
    0xf65e7085,
    0x7833fb67,
    0xd0bd2b00,
    0x1063f897,
    0x310a4b14,
    0x1181eb01,
    0x09c1eb03,
    0x3029f899,
    0xd50c079b,
    0x8034f8df,
    0xf8892209,
    0xf8d8202a,
    0x462a3320,
    0x46384649,
    0xf8894798,
    0x2300502a,
    0xe7a17033,
    0x00173250,
    0x00178bf8,
    0x001cf158,
    0x001cefbc,
    0x001cf1a0,
    0x00178c04,
    0x00171a30,
    0x001cefd0,
    0x00175aa8,
    0x500007dd,
    0x010002f2,
    0x00000000,
    0x00000000,
    0x5f6c6168,
    0x6863616d,
    0x62615f77,
    0x69745f73,
    0x5f72656d,
    0x646e6168,
    0x5f72656c,
    0x63746170,
    0x00000068,
    0x635f6372,
    0x6b636568,
    0x7461705f,
    0x00006863,
    0x625f6d6d,
    0x745f6e63,
    0x736e6172,
    0x5f74696d,
    0x63746170,
    0x00000068,
    0x625f6d6d,
    0x745f6e63,
    0x736e6172,
    0x7474696d,
    0x705f6465,
    0x68637461,
    0x00000000,
    0x00000000,
    0x00000000,
    0x00000000,
    0x00000000,
    0x00000000,
    0x00000000,
    0x00000000,
    0x00000000,
    0x00000000,
    0x00000000,
    0x00000000,
    0x00,
};

uint32_t VAR_WITH_VERx(patch_tbl, 3)[][2] =
{
    #if PLF_WIFI_AUDIO
    {WIFI_SETTINGS_OFST(thresh_param.beacon_linkloss_thd),         0x00003220}, // .bam_inactivity_to_duration0, .ps_tx_error_max = 50 bcn[0x32], .beacon_linkloss_thd = 32 bcn[0x20]
    {WIFI_SETTINGS_OFST(thresh_param.deepsleep_notallowed_offset), 0x07D02710}, // .deepsleep_notallowed_offset = 10 * 1000[0x2710], .ps_activity_to_us = 2000[0x07D0]
    #else
    {WIFI_SETTINGS_OFST(thresh_param.deepsleep_notallowed_offset), 0x4e202710}, // .deepsleep_notallowed_offset = 10 * 1000[0x2710], .ps_activity_to_us = 20000[0x4e20]
    #endif
    //{WIFI_SETTINGS_OFST(thresh_param.ps_activity_bcmc_to_us), 0x1f400fa0}, // .ps_activity_bcmc_to_us = 4000, .ps_activity_uc_to_us = 8000
    {WIFI_SETTINGS_OFST(thresh_param.lp_wakeup_offset), 0x080503e8}, // .lp_wakeup_offset = 1000, .tx_he_tb_prog_time = 5, .tx_agg_finish_dur = 8
    {WIFI_SETTINGS_OFST(host_if_param.host_type),       0x00000003}, // .host_type = 3,.sdio_desc_cnt = 0
    {WIFI_SETTINGS_OFST(host_if_param.pkt_cnt_128),     0x00000000}, // .pkt_cnt_128, .pkt_cnt_1600 = 0
    #if PLF_WIFI_AUDIO
    #ifdef CFG_SOFTAP
    {WIFI_SETTINGS_OFST(host_if_param.pkt_cnt_1724),    0x00000011},
    #else
    {WIFI_SETTINGS_OFST(host_if_param.pkt_cnt_1724),    0x00000011},
    #endif
    #else
    {WIFI_SETTINGS_OFST(host_if_param.pkt_cnt_1724),    0x00000011},
    #endif
    {WIFI_SETTINGS_OFST(host_if_param.buf_base_addr),   0x00000000},
    {WIFI_SETTINGS_OFST(host_if_param.desc_base_addr),  0x00000000},
    {WIFI_SETTINGS_OFST(host_if_param.desc_size),       0x00000000},
    {WIFI_SETTINGS_OFST(host_if_param.pkt_size),        0x00007800},
    #if (PLF_BT_STACK || PLF_BLE_STACK) && (PLF_WIFI_STACK)
    {WIFI_SETTINGS_OFST(host_if_param.ipc_base_addr),   0x00190000},
    {WIFI_SETTINGS_OFST(host_if_param.pkt_base_addr),   0x00190800},
    #else
    {WIFI_SETTINGS_OFST(host_if_param.ipc_base_addr),   0x00190000},
    {WIFI_SETTINGS_OFST(host_if_param.pkt_base_addr),   0x00190800},
    #endif
    {WIFI_SETTINGS_OFST(host_if_param.txdesc_cnt[0]),   NX_TXDESC_CNT0},
    {WIFI_SETTINGS_OFST(host_if_param.txdesc_cnt[1]),   NX_TXDESC_CNT1},
    {WIFI_SETTINGS_OFST(host_if_param.txdesc_cnt[2]),   NX_TXDESC_CNT2},
    {WIFI_SETTINGS_OFST(host_if_param.txdesc_cnt[3]),   NX_TXDESC_CNT3},
    {WIFI_SETTINGS_OFST(host_if_param.txdesc_cnt[4]),   NX_TXDESC_CNT4},
    {WIFI_SETTINGS_OFST(host_if_param.reord_buf_size),  NX_REORD_BUF_SIZE},
    {WIFI_SETTINGS_OFST(rx_ringbuf_conf.rx_ringbuf_start1), 0x00000000},
    {WIFI_SETTINGS_OFST(rx_ringbuf_conf.rx_ringbuf_size1), (24 * 1024)},
    {WIFI_SETTINGS_OFST(rx_ringbuf_conf.rx_ringbuf_start2), 0x00000000},
    {WIFI_SETTINGS_OFST(rx_ringbuf_conf.rx_ringbuf_size2), (1024 - 12)},
    #if FRAMES_11MBPS_ENABLED
    #if defined(CFG_WIFI_VOICE_ROLE_DONGLE)
    {WIFI_SETTINGS_OFST(thresh_param.tx_ac0_timeout),   20000}, // 20ms
    {WIFI_SETTINGS_OFST(thresh_param.tx_ac1_timeout),   20000}, // 20ms
    {WIFI_SETTINGS_OFST(thresh_param.tx_ac2_timeout),   20000}, // 20ms
    {WIFI_SETTINGS_OFST(thresh_param.tx_ac3_timeout),   20000}, // 20ms
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[0]),     0x00000a47},
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[1]),     0x00000643},
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[2]),     0x0005e431},
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[3]),     0x0002f321},
    #else
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[0]),     0x00000000},
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[1]),     0x00000000},
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[2]),     0x00000000},
    {WIFI_SETTINGS_OFST(ac_param_conf.ac_param[3]),     0x00000000},
    #endif
    #endif /* FRAMES_11MBPS_ENABLED */
#if CONFIG_SLEEP_LEVEL == 0
    {WIFI_SETTINGS_OFST(lp_level), 0x8d080000}, // .lp_level = 0, .bt_use_wifi_rf = 0, .debug_mask=0x8d08
#elif CONFIG_SLEEP_LEVEL == 1
    {WIFI_SETTINGS_OFST(lp_level), 0xffff0001}, // .lp_level = 1, .bt_use_wifi_rf = 0, .debug_mask=0xffff
#elif CONFIG_SLEEP_LEVEL >= 2
    {WIFI_SETTINGS_OFST(lp_level), 0xffff0002}, // .lp_level = 2, .bt_use_wifi_rf = 0, .debug_mask=0xffff
#endif
    #if PLF_BAND5G
    // Attention, GPIOs used by 5g fem maybe conflict with audio I2SM.
    {WIFI_SETTINGS_OFST(txgain_config.fix_txgain_en),   0xd0e0d003}, // .fix_txgain_en = 3, .fix_txgain_val = 0xd0, .fix_txgain_val_5g = 0xe0, .fix_1024qam_txgain = 0xd0
    {WIFI_SETTINGS_OFST(use_5g),                        0x00010001}, // .use_5g = 1, .clkgate_use_hwbcn = 0, .poweroff_use_hwbcn = 1
    #else
    {WIFI_SETTINGS_OFST(txgain_config.fix_txgain_en),   0xd0e0f301}, // .fix_txgain_en = 1, .fix_txgain_val = 0xf3, .fix_txgain_val_5g = 0xe0, .fix_1024qam_txgain = 0xd0
    #endif
};

uint32_t VAR_WITH_VERx(patch_tbl_func, 3)[][2] =
{
    { JUMP_TABLE_OFSTx(154, 3), 0x001ce001 }, //rc_check_patch
    { KE_EVT_HDLR_OFSTx( 0, 3), 0x001ce169 }, //rwnxl_reset_evt_patch
    { JUMP_TABLE_OFSTx(295, 3), 0x001ce315 }, //hw_reg_config_before_rf_calib_patch
    { JUMP_TABLE_OFSTx(146, 3), 0x001ce485 }, //ps_check_tx_frame_patch
    { JUMP_TABLE_OFSTx(302, 3), 0x001ce5b5 }, //rwnx_sleep_deepsleep_config_patch
    { JUMP_TABLE_OFSTx(196, 3), 0x001ce79d }, //sm_delete_resources_patch
    { JUMP_TABLE_OFSTx(256, 3), 0x001ce8a9 }, //txl_hwdesc_config_post_patch
    { SCANU_SCANING_OFSTx( 2, 3), 0x001cf591 }, //scan_rxu_mgt_ind_handler_patch
};

uint32_t VAR_WITH_VERx(patch_func, 3)[] =
{
    0x041f0e92d,
    0x0602cf890,
    0x0b0822e09,
    0x0d87f4604,
    0x04f4f4b4e,
    0x0eb06681a,
    0x0f9b21386,
    0x0eb072000,
    0x02a0003c3,
    0x05148f8d3,
    0x01886ea4f,
    0x06b62db68,
    0x030a1f895,
    0x05240f3c2,
    0x0f88d0759,
    0x0d45a2007,
    0x002fdf003,
    0x04943682b,
    0x020a1f885,
    0x0f503690a,
    0x033a033c3,
    0x0d8614293,
    0x029001ad1,
    0x0493eda04,
    0x0441343d2,
    0x0d95d428b,
    0x046282100,
    0x0f8e8f66f,
    0x030a2f895,
    0x033014937,
    0x0f0032200,
    0x0f8850303,
    0x0f88530a2,
    0x0f885209b,
    0x0690a20a3,
    0x0009b602a,
    0x03046f884,
    0x0f10db190,
    0x046280107,
    0x0fc3ef66e,
    0x03007f89d,
    0x0d04b2b00,
    0x00306eb08,
    0x003c3eb07,
    0x02152f893,
    0x00211f042,
    0x02152f883,
    0x0f66e4628,
    0x0b1a8fe73,
    0x0f8948de2,
    0x0f89d3046,
    0x0f4421007,
    0x0f0235200,
    0x085e20303,
    0x03046f884,
    0x04446bb59,
    0x007c6eb07,
    0x03152f897,
    0x00320f043,
    0x03152f887,
    0x0e8bdb002,
    0x02a0081f0,
    0x0f043d0a2,
    0x0e7a10202,
    0x0d1942d00,
    0x048164915,
    0x0f661224e,
    0x0e78efff7,
    0x0f8802300,
    0x0b0023046,
    0x081f0e8bd,
    0x01a9b4911,
    0x0d8a1428b,
    0x020a2f895,
    0x030a3f895,
    0x00382ea43,
    0x03046f884,
    0x06b63e7c2,
    0x01320f443,
    0x0e7ce6363,
    0x0f4236b63,
    0x063631300,
    0x0bf00e7ae,
    0x0001732b0,
    0x000176020,
    0x040501000,
    0x00001869f,
    0x0001cf6c4,
    0x0001cf5c4,
    0x0000186a0,
    0x041f0e92d,
    0x08310f3ef,
    0x0d40307db,
    0x04b57b672,
    0x0601a2201,
    0x049574c56,
    0x04d576823,
    0x0f44f3301,
    0x060236080,
    0x0fe08f661,
    0x04000f04f,
    0x0fc06f660,
    0x030ecf8d5,
    0x04b514798,
    0x068194a51,
    0x0417ff021,
    0x068196019,
    0x00110f041,
    0x069116019,
    0x069133164,
    0x02b001acb,
    0x04e4bdafb,
    0x02410f8d5,
    0x04f4a6833,
    0x07388f443,
    0x00301f043,
    0x047906033,
    0x068134a43,
    0x00310f023,
    0x068336013,
    0x07388f423,
    0x00301f023,
    0x0f6566033,
    0x0f655fadb,
    0x079bbf847,
    0x0d04f2b00,
    0x0681b4b3e,
    0x02b03781b,
    0x0783bd05a,
    0x0d0472b00,
    0x0797e4b3b,
    0x0f997681a,
    0x0f9973007,
    0x0f8dfe004,
    0x04838c0f8,
    0x01000f8dc,
    0x081e0f8d5,
    0x0f0024d30,
    0x04416020f,
    0x04433b276,
    0x0bfa84573,
    0x0fa5f4673,
    0x0f021fe83,
    0x0ea4101ff,
    0x0f8cc010e,
    0x068021000,
    0x002fff022,
    0x0020eea42,
    0x0f8dc6002,
    0x01eda1000,
    0x0fe82fa5f,
    0x0217ff421,
    0x0310eea41,
    0x01000f8cc,
    0x0f8b76802,
    0x0f422c008,
    0x0ea42227f,
    0x06002320e,
    0x04821692a,
    0x0f64eb25d,
    0x0fb012160,
    0x071fd210c,
    0x0230047c0,
    0x071bb481d,
    0x046324629,
    0x0fd34f661,
    0x0f44f491b,
    0x0f6616080,
    0x06823fd7f,
    0x04a0bb133,
    0x068123b01,
    0x0b90b6023,
    0x0b662b102,
    0x081f0e8bd,
    0x0681b4b14,
    0x0601a2200,
    0x0f826f646,
    0x02b00783b,
    0x079bbd0e6,
    0x0d19b2b00,
    0x0bf00e7e2,
    0x000175bfc,
    0x000172618,
    0x0001cf5d4,
    0x000171a3c,
    0x040320400,
    0x040501000,
    0x040340018,
    0x00017325c,
    0x0001732d4,
    0x04032011c,
    0x04033b3d4,
    0x000173268,
    0x0001cf5ec,
    0x0001cf5fc,
    0x000180000,
    0x04033b3ac,
    0x04d52b470,
    0x0682b4852,
    0x04a534c52,
    0x04e544953,
    0x063c0f423,
    0x07300f443,
    0x06803602b,
    0x003bcf423,
    0x05370f423,
    0x02360f443,
    0x06380f443,
    0x068236003,
    0x00360f023,
    0x068136023,
    0x033fef423,
    0x03398f443,
    0x0680b6013,
    0x063c0f023,
    0x07300f043,
    0x069ab600b,
    0x050fff5a0,
    0x0f0433814,
    0x061ab6380,
    0x0f4436803,
    0x060036300,
    0x0f4236a23,
    0x0f043737f,
    0x062230304,
    0x0f5a26803,
    0x0f5a2120f,
    0x0f42352fe,
    0x03a1c5380,
    0x06300f443,
    0x068136003,
    0x041daf501,
    0x003ccf023,
    0x0f043316c,
    0x0601303c4,
    0x0f003680b,
    0x0f5a5437f,
    0x0f44355f7,
    0x03d141378,
    0x07378f443,
    0x0682b600b,
    0x0f5a40c1b,
    0x0041b5400,
    0x0f0433c14,
    0x0602b0384,
    0x04d286823,
    0x06340f423,
    0x06300f443,
    0x0f8d06023,
    0x0f5023104,
    0x0f42352f8,
    0x0321823e0,
    0x03380f443,
    0x03104f8c0,
    0x0f0236813,
    0x0f0235376,
    0x0f5010307,
    0x0f04351f7,
    0x031045304,
    0x00307f043,
    0x0680b6013,
    0x05400f504,
    0x052eff102,
    0x05001f500,
    0x0f502341c,
    0x0401d223d,
    0x00244f602,
    0x0600d4b13,
    0x060323008,
    0x068036023,
    0x0f4234a11,
    0x0f423237f,
    0x0f4436300,
    0x060033332,
    0x0f44368cb,
    0x060cb6300,
    0x0f0236813,
    0x0f4430309,
    0x0bc705380,
    0x047706013,
    0x040344020,
    0x040344024,
    0x040344028,
    0x040580104,
    0x04033b3b8,
    0x04034402c,
    0x0ff000003,
    0x01a2e5108,
    0x040580108,
    0x043f8e92d,
    0x078234c3c,
    0x0d05e2b00,
    0x0d05c28ff,
    0x0d05a29ff,
    0x04f3a4b39,
    0x01080eb00,
    0x000c0eb03,
    0x065a4f44f,
    0x0fb057f86,
    0x0f8957506,
    0x02a002062,
    0x0f895d14b,
    0x02b003064,
    0x0f8dfd047,
    0x04b3190ec,
    0x02000f8d9,
    0x08ed1691b,
    0x080e0f8df,
    0x022036165,
    0x077624419,
    0x031e0f8d8,
    0x0000cf104,
    0x04b2a4798,
    0x0075b681b,
    0x04b29d531,
    0x030b6f893,
    0x0d12f2b00,
    0x0681b4b27,
    0x02b02781b,
    0x04a23d12f,
    0x068134925,
    0x00304f023,
    0x0784b6013,
    0x077222201,
    0x04a22b123,
    0x0f0236813,
    0x060134300,
    0x0b10b7a23,
    0x072233b01,
    0x02000f8d9,
    0x08ed14b17,
    0x0f8d8691a,
    0x0616531e0,
    0x077602004,
    0x048194411,
    0x0f44f4798,
    0x0fb0363a4,
    0x0685a7306,
    0x07280f442,
    0x02000605a,
    0x083f8e8bd,
    0x0681b4b0f,
    0x02a02781a,
    0x0f8d8d003,
    0x047983254,
    0x0480fe7f3,
    0x06802490f,
    0x07200f422,
    0x0680a6002,
    0x00201f022,
    0x0e7bd600a,
    0x0001792b4,
    0x000176020,
    0x000177cb0,
    0x040501000,
    0x04032004c,
    0x000171934,
    0x0001732d0,
    0x0001732c4,
    0x040320434,
    0x0001792c0,
    0x04033b390,
    0x04032008c,
    0x0001732a4,
    0x000171a3c,
    0x0f0002800,
    0x0e92d80a9,
    0x0f89043f0,
    0x0b0833064,
    0x0b9134604,
    0x0e8bdb003,
    0x04b5f83f0,
    0x0f8df4a5f,
    0x0f8d2c1bc,
    0x04e5ee470,
    0x04f5f4a5e,
    0x091b0f8df,
    0x081b0f8df,
    0x0f8c32002,
    0x0f8dc0180,
    0x0f8ccc008,
    0x0f04fe044,
    0x060180c01,
    0x0c000f886,
    0x06813693f,
    0x0f0236077,
    0x0460d0302,
    0x060134954,
    0x0f8d9680f,
    0x0f8b83000,
    0x08f9b10b2,
    0x0017f9100,
    0x04950463a,
    0x0fbbcf661,
    0x068134a4f,
    0x0030ff003,
    0x0d06c2b0b,
    0x03000f8d9,
    0x020b2f8b8,
    0x044138f9b,
    0x0d2c142bb,
    0x049496872,
    0x0f6612002,
    0x04a43fba9,
    0x0691268f3,
    0x02b001a9b,
    0x0f8b4da5e,
    0x04b442068,
    0x0f8936869,
    0x02a050d23,
    0x03a01d95f,
    0x07702fb01,
    0x03d23f893,
    0x0463a493f,
    0x0f6612002,
    0x0f8d9fb91,
    0x0f8b82000,
    0x08f9230b2,
    0x048344933,
    0x069044d3a,
    0x0680b441a,
    0x0f0221aba,
    0x0f0030003,
    0x043030303,
    0x0600b4836,
    0x060b26803,
    0x00301f043,
    0x0682b6003,
    0x0f3c36829,
    0x0f4210309,
    0x0f043717f,
    0x0f0210301,
    0x0430b0103,
    0x06803602b,
    0x0075b4422,
    0x0d50360f2,
    0x0f44f4b2b,
    0x0601a7200,
    0x0482b4c2a,
    0x0491e6823,
    0x0f0434a1e,
    0x060230308,
    0x0f0436803,
    0x060030302,
    0x0f043680b,
    0x0600b0301,
    0x0f5016911,
    0x069137196,
    0x02b001a5b,
    0x0b003dbfb,
    0x083f0e8bd,
    0x068134770,
    0x0030ff023,
    0x0e7956013,
    0x0491c4b15,
    0x03d23f893,
    0x02002463a,
    0x0fb3cf661,
    0x0f893e7a9,
    0x02a012d24,
    0x0f893d99e,
    0x0b12a2d23,
    0x02d23f893,
    0x0fb013a01,
    0x0e7957702,
    0x02d24f893,
    0x0bf00e78f,
    0x0e000e100,
    0x000171a3c,
    0x0001732b4,
    0x040320084,
    0x040501000,
    0x040328040,
    0x0001cf60c,
    0x04058001c,
    0x0001cf61c,
    0x0001e4000,
    0x0001cf638,
    0x040506000,
    0x040044084,
    0x040044100,
    0x040580010,
    0x040580018,
    0x0001cf624,
    0x0e000ed00,
    0x0001732a4,
    0x000171934,
    0x041f0e92d,
    0x046042302,
    0x021052206,
    0x04019f241,
    0x0fce2f65f,
    0x023022206,
    0x021054606,
    0x04017f241,
    0x0fcdaf65f,
    0x080e0f8df,
    0x046054933,
    0x07080f44f,
    0x0fae8f661,
    0x0fdf8f665,
    0x0f64d4620,
    0x02700fea5,
    0x0006cf894,
    0x03024f8d8,
    0x070374798,
    0x03063f894,
    0x0482a7073,
    0x0010cf1a6,
    0x0f954f660,
    0x03064f894,
    0x0f894bb7b,
    0x02bff306c,
    0x02301d00d,
    0x022062100,
    0x0f65f200c,
    0x04601fcb1,
    0x0306cf894,
    0x0390cf801,
    0x0f660481e,
    0x06c23f93f,
    0x02301b16b,
    0x022062100,
    0x0f65f2039,
    0x04601fca1,
    0x03063f894,
    0x0390cf801,
    0x0f6604816,
    0x02300f92f,
    0x0f894702b,
    0x0706b3063,
    0x0010cf1a5,
    0x0f6604811,
    0x0e8bdf925,
    0x0f66541f0,
    0x02206bf03,
    0x046392304,
    0x0f65f201e,
    0x07087fc85,
    0x03063f894,
    0x0f1a070c3,
    0x04808010c,
    0x0f912f660,
    0x031d8f8d8,
    0x047984806,
    0x0775f4b06,
    0x0f4236863,
    0x060637380,
    0x0bf00e7b5,
    0x0001cf648,
    0x00017af08,
    0x0001792c0,
    0x0001792b4,
    0x000171a3c,
    0x043f0e92d,
    0x06cc56b43,
    0x01800f413,
    0x04604b083,
    0x00728f105,
    0x0f403d008,
    0x0f5b31360,
    0x0f0001f20,
    0x0b003808f,
    0x083f0e8bd,
    0x06d068dc3,
    0x0d538071a,
    0x09240f8df,
    0x02000f8d9,
    0x02000f9b2,
    0x0f2c02a00,
    0x06a7180c3,
    0x06a32b909,
    0x006186891,
    0x0f894d509,
    0x02b003043,
    0x080d1f040,
    0x03045f894,
    0x0f0402b00,
    0x06cf380d3,
    0x003f0f423,
    0x0790b64f3,
    0x0f01363b7,
    0x0bf080f01,
    0x07800f44f,
    0x0f8c62300,
    0x065338048,
    0x06e2a6aeb,
    0x0f0436372,
    0x062eb0302,
    0x0f6524620,
    0x06ce2fd4b,
    0x0f0436a53,
    0x062530310,
    0x0e8bdb003,
    0x04b6e83f0,
    0x03428f8d3,
    0x06deb4798,
    0x0f89464b3,
    0x0496b202b,
    0x060a4f44f,
    0x01202fb00,
    0x02062f892,
    0x0f894bb32,
    0x04967202c,
    0x01282eb02,
    0x002c2eb01,
    0x02124f8d2,
    0x0d51b0692,
    0x0f4128de2,
    0x06be25f00,
    0x0bf146bd2,
    0x01200f3c2,
    0x002c0f3c2,
    0x0f8d6b982,
    0x0f8bcc024,
    0x004102000,
    0x0d509b291,
    0x0200ae9d6,
    0x0010ef3c1,
    0x03a043804,
    0x01000f8ac,
    0x0200ae9c6,
    0x08160f8df,
    0x0f8d863b7,
    0x06d272000,
    0x02000f9b2,
    0x0db472a00,
    0x0b90a6a7a,
    0x068926a3a,
    0x063c0f423,
    0x0791264b3,
    0x0bf5c07d2,
    0x07300f443,
    0x0e79f64b3,
    0x06c866b83,
    0x022c2f3c3,
    0x063372a05,
    0x0f403d10d,
    0x06cea63c0,
    0x06f80f5b3,
    0x0f44fbf14,
    0x0f44f3380,
    0x0f4223300,
    0x0431a3240,
    0x0f10464ea,
    0x0f6500038,
    0x0f8d4ff01,
    0x06ba2c04c,
    0x0f8dc88b0,
    0x06de93024,
    0x06aea63ea,
    0x00408f040,
    0x0f44180b4,
    0x06e2c60c0,
    0x0f04262f4,
    0x064300202,
    0x00310f043,
    0x0463962ea,
    0x07082f506,
    0x0f8cc2234,
    0x0b0033024,
    0x043f0e8bd,
    0x0b8a6f670,
    0x02a006ce2,
    0x06a7ad03c,
    0x0d1b52a00,
    0x0b1926a3a,
    0x0e7b06cb3,
    0x06a71b32d,
    0x0f47f2900,
    0x06a32af3c,
    0x08de3b10a,
    0x04923e736,
    0x0f2404823,
    0x0f66112b9,
    0x06a32fb37,
    0x0491fe7f5,
    0x0f240481f,
    0x0f66112b9,
    0x06a3afb2f,
    0x02220e7e4,
    0x091014620,
    0x0ff70f66a,
    0x0e72c9901,
    0x091018922,
    0x0f66c4620,
    0x09901f889,
    0x04914e725,
    0x0f44f4815,
    0x0f66172d9,
    0x06a71fb19,
    0x0f8d9b9a9,
    0x0f9b33000,
    0x02b003000,
    0x0e7d8dbcf,
    0x072d9f44f,
    0x0480d490b,
    0x0fb0af661,
    0x0b9426a7a,
    0x03000f8d8,
    0x03000f9b3,
    0x0dbb72b00,
    0x08de3e7d1,
    0x06cb3e6f9,
    0x0bf00e768,
    0x000171a3c,
    0x000177cb0,
    0x000176020,
    0x0001cf6ac,
    0x0001cf67c,
    0x0001cf65c,
    0x0001732b0,
    0x042984b1d,
    0x03b0dd812,
    0x0d91b4298,
    0x0207af5a0,
    0x06340f46f,
    0x0280c4418,
    0x0e8dfd814,
    0x00f11f000,
    0x0211f0d13,
    0x027252313,
    0x0001d2b29,
    0x042984b13,
    0x03302d004,
    0x0d1074298,
    0x047702002,
    0x047702001,
    0x047702000,
    0x0477020ff,
    0x01372f5a3,
    0x042983b03,
    0x020ffbf14,
    0x047702004,
    0x04770200b,
    0x047702003,
    0x047702005,
    0x047702006,
    0x047702007,
    0x047702008,
    0x047702009,
    0x04770200a,
    0x0000fac0d,
    0x00050f202,
    0x01c434401,
    0x0d9174299,
    0x0e003b470,
    0x042991c6b,
    0x0d90e4628,
    0x078067844,
    0x02e301ca3,
    0x00500eb03,
    0x042a9d1f4,
    0x0b128d305,
    0x0d9022b13,
    0x0bc707014,
    0x020004770,
    0x04770bc70,
    0x047702000,
    0x043f8e92d,
    0x042a0180c,
    0x0d30846a0,
    0x0f890e032,
    0x0781ee001,
    0x00502f10e,
    0x044282edd,
    0x01c45d007,
    0x0460342ac,
    0x02300d8f3,
    0x0e8bd4618,
    0x0428483f8,
    0x02b00d3f9,
    0x0f103d0f8,
    0x045e00c07,
    0x04f15d3f3,
    0x026001c9c,
    0x0f817e001,
    0x0f8946f01,
    0x045b19000,
    0x00401f104,
    0x045a4d108,
    0x02d17d1f5,
    0x0f882d9e3,
    0x04618e000,
    0x083f8e8bd,
    0x045801b49,
    0x0d901b289,
    0x0e7d4180c,
    0x0681b4b08,
    0x03000f9b3,
    0x0dad22b00,
    0x0d0d04540,
    0x048064905,
    0x0621ef240,
    0x0fa48f661,
    0x0e7c92300,
    0x0001cf6a4,
    0x0001732b0,
    0x0001cf6d4,
    0x0001cf690,
    0x01c434401,
    0x0d9174299,
    0x0e003b470,
    0x042991c6b,
    0x0d90e4628,
    0x078067844,
    0x02e441ca3,
    0x00500eb03,
    0x042a9d1f4,
    0x0b128d305,
    0x0d9022b15,
    0x0bc707014,
    0x020004770,
    0x04770bc70,
    0x047702000,
    0x042984b27,
    0x03b12d81c,
    0x0d9174298,
    0x0207af5a0,
    0x06340f46f,
    0x028114418,
    0x0e8dfd810,
    0x00b0df000,
    0x02c2a2809,
    0x00f32302e,
    0x00f383634,
    0x0263e3c3a,
    0x047702004,
    0x047702003,
    0x047702002,
    0x0477020ff,
    0x042984b18,
    0x0d908d00f,
    0x042984b17,
    0x03301d0f4,
    0x0bf144298,
    0x0200320ff,
    0x03b014770,
    0x0bf144298,
    0x0201220ff,
    0x020134770,
    0x020114770,
    0x020054770,
    0x020064770,
    0x020074770,
    0x020084770,
    0x020094770,
    0x0200a4770,
    0x0200b4770,
    0x0200c4770,
    0x0200d4770,
    0x0200e4770,
    0x0200f4770,
    0x020104770,
    0x0bf004770,
    0x0000fac12,
    0x000147202,
    0x00050f201,
    0x041f0e92d,
    0x08e524616,
    0x0e9c62300,
    0x006d3330d,
    0x0d56eb082,
    0x0eb014607,
    0x046040800,
    0x07865e007,
    0x01cab7820,
    0x0eb032830,
    0x0d0670204,
    0x01c634614,
    0x0d8f44598,
    0x00207f10d,
    0x0f7ff4638,
    0x04601ff1b,
    0x0d04c2800,
    0x0f89d6880,
    0x023022007,
    0x06373ba00,
    0x0feb2f7ff,
    0x0f0402800,
    0x0898c80b6,
    0x0310e3a0c,
    0x02a03b19c,
    0x02501dd11,
    0x02a03e001,
    0x06808dd0d,
    0x0f7ffba00,
    0x03a04fea1,
    0x0b1203104,
    0x0fa058f73,
    0x04318f000,
    0x03c018770,
    0x02a01d1ef,
    0x0460cdd1b,
    0x05b02f834,
    0x02a05b1bd,
    0x03a06dd15,
    0x0f0221d8b,
    0x0441a0203,
    0x0e0012101,
    0x0d00c4294,
    0x0ba006820,
    0x0ff50f7ff,
    0x0b1203404,
    0x0fa016b73,
    0x04318f000,
    0x03d016370,
    0x0b002d1f0,
    0x081f0e8bd,
    0x07838787b,
    0x028441c9a,
    0x00107eb02,
    0x08081f000,
    0x01c7b460f,
    0x0d8f34598,
    0x023012202,
    0x087336372,
    0x0e8bdb002,
    0x0230181f0,
    0x0b0026373,
    0x081f0e8bd,
    0x0d3994590,
    0x0d0972c00,
    0x0d9952b13,
    0x05007f88d,
    0x0ba006860,
    0x0fe52f7ff,
    0x0d15d2800,
    0x0f1048922,
    0x0f1a5010a,
    0x02a000708,
    0x080b5f000,
    0x0e0032401,
    0x0dd112b03,
    0x04629461f,
    0x0ba006808,
    0x0fe3ef7ff,
    0x01d0d1f3b,
    0x0f8b6b130,
    0x0fa04c03a,
    0x0ea40f000,
    0x08770000c,
    0x0d1eb3a01,
    0x03106882a,
    0x0b1a23f06,
    0x0dd122f03,
    0x0e0022401,
    0x0f3402f03,
    0x068088087,
    0x0f7ffba00,
    0x03f04fef1,
    0x0b1203104,
    0x0fa046b73,
    0x04318f000,
    0x03a016370,
    0x02f01d1ee,
    0x0460cdd9d,
    0x02b011ebb,
    0x02b02f834,
    0x08823dd06,
    0x01d0c1f3d,
    0x01403eb04,
    0x01303eba5,
    0x00fc0f012,
    0x02b03d08d,
    0x06820dd6c,
    0x0f7ffba00,
    0x02800fe01,
    0x08f32d085,
    0x040832301,
    0x087334313,
    0x08f34e77f,
    0x0fa032301,
    0x04320f000,
    0x0e7428730,
    0x0fa032301,
    0x08730f000,
    0x04588e79c,
    0x02f00d380,
    0x0af7ef43f,
    0x0f67f2a15,
    0x0f88daf7b,
    0x088b93007,
    0x01f1c1dba,
    0x0d0552900,
    0x0e0032701,
    0x0dd102b03,
    0x04662461c,
    0x0ba006810,
    0x0fea2f7ff,
    0x0f1021f23,
    0x0b1200c04,
    0x0fa076b75,
    0x04328f000,
    0x039016370,
    0x02b01d1ec,
    0x0af4df77f,
    0x01000f8bc,
    0x01fa21d97,
    0x02a03b1a9,
    0x0af45f77f,
    0x0e0022401,
    0x0f77f2a03,
    0x06838af40,
    0x0f7ffba00,
    0x03704fdb5,
    0x0b1203a04,
    0x0fa048f73,
    0x04318f000,
    0x039018770,
    0x02a03d1ee,
    0x0af2ff77f,
    0x0ba006838,
    0x0fda4f7ff,
    0x0f43f2800,
    0x0e7a0af28,
    0x0f77f2f01,
    0x0880baf24,
    0x00fc0f013,
    0x0af1ff43f,
    0x0f0438f33,
    0x087330320,
    0x0880ae719,
    0x0070af1a5,
    0x0010cf104,
    0x0f47f2a00,
    0x0880aaf5f,
    0x0e776340e,
    0x037088811,
    0x029001f9a,
    0x0e7d9d1c4,
    0x0b4704b11,
    0x0f5034606,
    0x0e0066400,
    0x08832895d,
    0x0d00b4295,
    0x042a33340,
    0x07a1ad013,
    0x00008f103,
    0x0d1f32a00,
    0x0d0f52900,
    0x04770bc70,
    0x08872899d,
    0x0d1ef4295,
    0x088b289dd,
    0x0d0f54295,
    0x042a33340,
    0x02000d1eb,
    0x04770bc70,
    0x00017af38,
    0x04ff0e92d,
    0x0ed2d4d77,
    0x0682f8b02,
    0x0f897b087,
    0x09301314a,
    0x020044604,
    0x0fb1cf65f,
    0x0d0052801,
    0x0b0072000,
    0x08b02ecbd,
    0x08ff0e8bd,
    0x0462b8ba1,
    0x07a1a2600,
    0x01886ea4f,
    0x0d17b2a00,
    0x0380cf895,
    0x0f14007db,
    0x0f1088081,
    0x044ab0b08,
    0x00908eb05,
    0x01002f8ab,
    0x0f8ab8be3,
    0x08c233004,
    0x03006f8ab,
    0x0202df894,
    0x0302cf894,
    0x02302ea43,
    0x03038f8a9,
    0x046a28de3,
    0x02b30f83a,
    0x0303af8a9,
    0x00301f003,
    0x00302f1c3,
    0x00124f1a2,
    0x0f10d4650,
    0x0f8a90216,
    0x0ee083032,
    0x0f65f1a10,
    0x02800fee1,
    0x0809ff000,
    0x02016f89d,
    0x02010f889,
    0x00111f108,
    0x0b1524429,
    0x0f1c3460b,
    0x044110c02,
    0x0f81218c2,
    0x0f803200c,
    0x042992b01,
    0x0f895d1f8,
    0x02b003833,
    0x08172f040,
    0x0380af895,
    0x0d1522b00,
    0x0c14cf897,
    0x00f00f1bc,
    0x0f108d04d,
    0x0eb050111,
    0x0ee080208,
    0x0f8cdaa90,
    0x04699800c,
    0x0442946a0,
    0x04692463c,
    0x0f109e007,
    0x045cc0901,
    0x00721f107,
    0x0f3404662,
    0x0f8978190,
    0x0b35b30fc,
    0x02010f89a,
    0x0d1f0429a,
    0x000fdf107,
    0x0f66f9102,
    0x02800fcdd,
    0x081bff000,
    0x0c14cf894,
    0x0e7e49902,
    0x0428a895a,
    0x03601d048,
    0x0f1032e20,
    0x0f47f0340,
    0x0e76baf76,
    0x0380cf8b5,
    0x0f47f428b,
    0x08be2af67,
    0x0380ef8b5,
    0x0f47f429a,
    0x08c22af61,
    0x03810f8b5,
    0x0f47f429a,
    0x0e76caf5b,
    0x0ee184644,
    0x0f8ddaa90,
    0x04662800c,
    0x0f43f4591,
    0x0ee18af51,
    0x046501a10,
    0x0ff5af65f,
    0x079a2b370,
    0x02a007883,
    0x0811ef040,
    0x0290d1e59,
    0x08117f200,
    0x0f0002b0e,
    0x0eb038181,
    0x0f6030383,
    0x046101167,
    0x0f94ef663,
    0x0eb053601,
    0x0eb050308,
    0x063581686,
    0x03009f994,
    0x02004f996,
    0x0da19429a,
    0x0e0177133,
    0x08be28998,
    0x0d1b24290,
    0x08c2289d8,
    0x0d1ae4290,
    0x0f889e72e,
    0x0e7700010,
    0x00017af38,
    0x0eb053601,
    0x0f9941686,
    0x0f9962009,
    0x0429a3004,
    0x08104f300,
    0x03a10ee18,
    0x0465ab29f,
    0x046504639,
    0x0fd7af7ff,
    0x0380af895,
    0x0f0002b00,
    0x0eb0580bc,
    0x046130208,
    0x0f8538e51,
    0x0f8df0f0a,
    0x0889ac2fc,
    0x0f44f9b01,
    0x0fb0666a4,
    0x04eb9f303,
    0x018f39302,
    0x06008f85c,
    0x00168f8c3,
    0x0216cf8a3,
    0x0f8a39802,
    0x022ff1190,
    0x0f88349b2,
    0x0f8832165,
    0x0f8c321c2,
    0x0f893619c,
    0x0f100316e,
    0x0448b0bf0,
    0x0f0402b00,
    0x09b0180d7,
    0x04baa461a,
    0x066a4f44f,
    0x00908eb05,
    0x03602fb06,
    0x00e10f109,
    0x076b7f506,
    0x00930f109,
    0x0e8bc46f4,
    0x045cc000f,
    0x060716030,
    0x060f360b2,
    0x0f10646e6,
    0x0d1f30610,
    0x03000f89c,
    0x09b027033,
    0x072d0f503,
    0x046199b01,
    0x0eb054b99,
    0x0f44f0908,
    0x0fb0666a4,
    0x0441a3601,
    0x03034f8d9,
    0x03194f8c6,
    0x0f8a62300,
    0x0f8c631c6,
    0x0463931d0,
    0x092034650,
    0x0ff8af661,
    0x03034f8d9,
    0x0789b9a03,
    0x0d07e2b00,
    0x04e8b9b02,
    0x072d8f503,
    0x0f10d4432,
    0x046390317,
    0x0f6624650,
    0x0b180f921,
    0x0f44f9a01,
    0x0fb0363a4,
    0x0f8b36302,
    0x0f8d3119e,
    0x0f44121d0,
    0x0f0427100,
    0x0f8a30201,
    0x0f8c3119e,
    0x0f8df21d0,
    0x0f8999200,
    0x007de3176,
    0x09a01d50a,
    0x04a794611,
    0x063a4f44f,
    0x02301fb03,
    0x021d0f8d3,
    0x0d47a07d0,
    0x0460e2100,
    0x0465a4630,
    0x0fc96f663,
    0x04639465a,
    0x0f6614650,
    0x0465aff91,
    0x046504639,
    0x0ff96f661,
    0x04639465a,
    0x0f6614650,
    0x09a01fff9,
    0x04a694611,
    0x063a4f44f,
    0x02301fb03,
    0x0f8d32101,
    0x0f88521d0,
    0x0f0421834,
    0x0f8c34200,
    0x0eb0521d0,
    0x07a1b0308,
    0x088abb913,
    0x080ab3301,
    0x046204445,
    0x023042401,
    0x0f241220b,
    0x0722c0104,
    0x0ff1ef65e,
    0x0e6364620,
    0x00011f108,
    0x044284958,
    0x0f66f2207,
    0x02800fb8f,
    0x0ae2cf47f,
    0x0f64fe6d9,
    0x0e6ec71ff,
    0x0d1fa2a01,
    0x029a41e59,
    0x0eb03d8f7,
    0x0f5030383,
    0x03108519c,
    0x04610e6e1,
    0x0f6632101,
    0x0f010f9db,
    0x0bf1a000f,
    0x0f080fab0,
    0x0031ff1c0,
    0x0f8862301,
    0x0e77131c5,
    0x079a088a1,
    0x0f820f663,
    0x00308eb05,
    0x07a636358,
    0x0e6f17133,
    0x0f2039b02,
    0x04b3e106f,
    0x0f66f4418,
    0x02800fd79,
    0x0af1ff43f,
    0x04644e73b,
    0x0aa90ee18,
    0x0800cf8dd,
    0x0465ae69e,
    0x046504639,
    0x0f6629303,
    0x09b03f8cf,
    0x0f43f2800,
    0x0f8d3af7b,
    0x0f04221d0,
    0x0ee180202,
    0x0f8c31a10,
    0x0465021d0,
    0x0ff12f65f,
    0x02176f899,
    0x046060751,
    0x00792d426,
    0x09a01d40c,
    0x04a284611,
    0x063a4f44f,
    0x02301fb03,
    0x011d0f8d3,
    0x00108f011,
    0x0af5ef43f,
    0x0f5039b02,
    0x04b217288,
    0x0441a4639,
    0x0f6624650,
    0x0b9d8f8c7,
    0x0e7514601,
    0x011b4f640,
    0x04627e67f,
    0x0aa90ee18,
    0x0f8974644,
    0x0f8dd214c,
    0x0e65d800c,
    0x0f5039b02,
    0x04b15728e,
    0x0441a4639,
    0x0f6624650,
    0x09b03f8cd,
    0x0f899b9b0,
    0x0e7ca2176,
    0x046119a01,
    0x0f44f4a0e,
    0x0fb0363a4,
    0x046502301,
    0x021d0f8d3,
    0x00204f042,
    0x01a10ee18,
    0x021d0f8c3,
    0x0fee6f65f,
    0x0e7234601,
    0x011d0f8d3,
    0x00008f041,
    0x001d0f8c3,
    0x04639465a,
    0x0f6624650,
    0x0e7dcf8ff,
    0x000177cb0,
    0x0001cf69c,
    0x00017af70,
    0x00017ad7c,
    0x04a0b4b0a,
    0x0f893681b,
    0x0f44f314a,
    0x0fb0060a4,
    0x046082303,
    0x03087f993,
    0x0f991b11b,
    0x0429a2009,
    0x0f7ffdb01,
    0x02000bd59,
    0x0bf004770,
    0x00017af38,
    0x000177cb0,
    0x0735f6372,
    0x03d212073,
    0x04c554e20,
    0x00000004c,
    0x0786e7772,
    0x065725f6c,
    0x05f746573,
    0x05f747665,
    0x063746170,
    0x0000a0d68,
    0x061647075,
    0x025206574,
    0x025202c64,
    0x0000a0d64,
    0x065736572,
    0x06f642074,
    0x00a0d656e,
    0x000000000,
    0x020676663,
    0x025206425,
    0x064252064,
    0x000000a0d,
    0x078253d74,
    0x000000a0d,
    0x020746f6e,
    0x074736170,
    0x06425203a,
    0x00d64252c,
    0x00000000a,
    0x073736170,
    0x06425203a,
    0x00d64252c,
    0x00000000a,
    0x0656c6564,
    0x072206574,
    0x072756f65,
    0x00d736563,
    0x00000000a,
    0x05f6c7874,
    0x066667562,
    0x0675f7265,
    0x074287465,
    0x073656478,
    0x021202963,
    0x0554e203d,
    0x000004c4c,
    0x02d646874,
    0x07269663e,
    0x0705f7473,
    0x0705f6462,
    0x000007274,
    0x072646461,
    0x0203d3d20,
    0x000646e65,
    0x045524944,
    0x0002d5443,
    0x001f25000,
    0x000000001,
    0x05f6c7874,
    0x066667562,
    0x06d5f7265,
    0x064686361,
    0x065675f72,
    0x000000074,
    0x0635f6372,
    0x06b636568,
    0x07461705f,
    0x000006863,
    0x063616d5f,
    0x06973765f,
    0x069665f65,
    0x000646e,
};

#define AON_PATCH_START_ADDR_U02    0x001E4D28
#define AON_PATCH_NUM_U02           0x001E4D2C
#define PATCH_STORE_ADDR_U02        0x001E6000
#define FW_PATCH_ADDR_U02           0x001CE000
#define AON_PATCH_START_ADDR_U03    0x001E4D28
#define AON_PATCH_NUM_U03           0x001E4D2C
#define PATCH_STORE_ADDR_U03        0x001E6000
#define FW_PATCH_ADDR_U03           0x001CE000

#define AON_PATCH_START_ADDRx(v)    MCAT(AON_PATCH_START_ADDR_U0, v)
#define AON_PATCH_START_ADDR        AON_PATCH_START_ADDRx(CFG_ROM_VER)
#define AON_PATCH_NUMx(v)           MCAT(AON_PATCH_NUM_U0, v)
#define AON_PATCH_NUM               AON_PATCH_NUMx(CFG_ROM_VER)
#define PATCH_STORE_ADDRx(v)        MCAT(PATCH_STORE_ADDR_U0, v)
#define PATCH_STORE_ADDR            PATCH_STORE_ADDRx(CFG_ROM_VER)
#define FW_PATCH_ADDRx(v)           MCAT(FW_PATCH_ADDR_U0, v)
#define FW_PATCH_ADDR               FW_PATCH_ADDRx(CFG_ROM_VER)

patch_tbl_array_t patch_tbl;
patch_tbl_array_t patch_tbl_func;
uint32_t *patch_func;
uint32_t patch_tbl_size;
uint32_t patch_tbl_func_size;
uint32_t patch_func_size;
uint32_t aon_patch_start_addr;
uint32_t aon_patch_num;
uint32_t patch_store_addr;
uint32_t fw_patch_addr;

void wifi_patch_prepare(void)
{
    #if (CFG_ROM_VER == 255)
    uint8_t chip_id = ChipIdGet(0);
    if (chip_id == 0x03) {
        patch_tbl               = VAR_WITH_VERx(patch_tbl, 2);
        patch_tbl_func          = VAR_WITH_VERx(patch_tbl_func, 2);
        patch_func              = VAR_WITH_VERx(patch_func, 2);
        patch_tbl_size          = sizeof(VAR_WITH_VERx(patch_tbl, 2)) / 4;
        patch_tbl_func_size     = sizeof(VAR_WITH_VERx(patch_tbl_func, 2)) / 4;
        patch_func_size         = sizeof(VAR_WITH_VERx(patch_func, 2)) / 4;
        aon_patch_start_addr    = AON_PATCH_START_ADDRx(2);
        aon_patch_num           = AON_PATCH_NUMx(2);
        patch_store_addr        = PATCH_STORE_ADDRx(2);
        fw_patch_addr           = FW_PATCH_ADDRx(2);
    } else if (chip_id == 0x07) {
        patch_tbl               = VAR_WITH_VERx(patch_tbl, 3);
        patch_tbl_func          = VAR_WITH_VERx(patch_tbl_func, 3);
        patch_func              = VAR_WITH_VERx(patch_func, 3);
        patch_tbl_size          = sizeof(VAR_WITH_VERx(patch_tbl, 3)) / 4;
        patch_tbl_func_size     = sizeof(VAR_WITH_VERx(patch_tbl_func, 3)) / 4;
        patch_func_size         = sizeof(VAR_WITH_VERx(patch_func, 3)) / 4;
        aon_patch_start_addr    = AON_PATCH_START_ADDRx(3);
        aon_patch_num           = AON_PATCH_NUMx(3);
        patch_store_addr        = PATCH_STORE_ADDRx(3);
        fw_patch_addr           = FW_PATCH_ADDRx(3);
    }
    #else
    patch_tbl               = VAR_WITH_VER(patch_tbl);
    patch_tbl_func          = VAR_WITH_VER(patch_tbl_func);
    patch_func              = VAR_WITH_VER(patch_func);
    patch_tbl_size          = sizeof(VAR_WITH_VER(patch_tbl)) / 4;
    patch_tbl_func_size     = sizeof(VAR_WITH_VER(patch_tbl_func)) / 4;
    patch_func_size         = sizeof(VAR_WITH_VER(patch_func)) / 4;
    aon_patch_start_addr    = AON_PATCH_START_ADDR;
    aon_patch_num           = AON_PATCH_NUM;
    patch_store_addr        = PATCH_STORE_ADDR;
    fw_patch_addr           = FW_PATCH_ADDR;
    #endif
}
